function workontimeseries (gijon, coruna)
%function workontimeseries (gijon, coruna)

latc = 43.359;
lonc = -8.388;

latg = 43.559;
long = -5.697;

time = 86400.0/600.0*[1:47952] - 86400.0/6.0;

%GIJON
%Create netcdf dimensions and variables
out = 'MOHIDgijon.nc';
create_output_nc_file(out,length(time));

%Write the variables in the netcdf file
nc_varput(out,'time',time);
nc_varput(out,'longitude',long);
nc_varput(out,'latitude',latg);
nc_varput(out,'ssh',gijon);

%CORUNA
%Create netcdf dimensions and variables
out = 'MOHIDcoruna.nc';
create_output_nc_file(out,length(time));

%Write the variables in the netcdf file
nc_varput(out,'time',time);
nc_varput(out,'longitude',long);
nc_varput(out,'latitude',latg);
nc_varput(out,'ssh',coruna);

nc_dump(out);

%test if things worked out...
testlat=nc_varget(out,'latitude');
testlon=nc_varget(out,'longitude');
testtime=nc_varget(out,'time');
testssh=nc_varget(out,'ssh');

end

function create_output_nc_file(out, size)
        
    nc_create_empty(out, nc_clobber_mode);
    nc_add_dimension(out, 'time', size);
    nc_add_dimension(out, 'longitude', 1);
    nc_add_dimension(out, 'latitude', 1);

    s_ncvars = struct ( 'Name', ...
                       {   'time',...
                           'longitude',...
                           'latitude',...
                           'ssh'}, ...
                  'Nctype', ...
                       {   'double',...
                           'float',...
                           'float',...
                           'float'}, ...
                  'Dimension', ...
                       {   {'time'},...
                           {'longitude'},...
                           {'latitude'},...
                           {'time' 'latitude' 'longitude'}}, ...
                  'Attribute', ...
                       {   struct( 'Name','units',...
                                    'Value','seconds since 2004-02-01 00:00:00' ), ...
                           struct( 'Name','units',...
                                   'Value','degrees_east' ), ...
                           struct( 'Name','units',...
                                   'Value','degrees_north' ), ...
                           struct( 'Name','units',...
                                   'Value','metres' ), ...
                        });

    for i=1:length(s_ncvars)                     
       nc_addvar(out, s_ncvars(i));
    end
    
end
